package cn.larry.tools.utils;

import java.util.ArrayList;
import java.util.List;

public class DomainGenUtil {
	private static String[] YUNMU = { "a", "e", "i", "o", "u", "v", "an", "ai",
			"ao", "ang", "ou", "ong", "en", "er", "ei", "eng", "ia", "iu",
			"ie", "in", "ing", "un", "uo", "ui", "ue", "ua", "iao", "ian",
			"iang", "iong", "uai", "uan", "uang" };
	private static String[] SHENGMU = { "b", "p", "m", "f", "d", "t", "n", "l",
			"g", "k", "h", "j", "q", "x", "zh", "ch", "sh", "r", "z", "c", "s",
			"y", "w", "" };

	
	
	public static List<String> genPinyin2() {
		List<String> list = new ArrayList<String>((int)Math.pow(2,21));
		for (String shengmu1 : SHENGMU) {
			for (String yunmu1 : YUNMU) {
				for (String shengmu2 : SHENGMU) {
					for (String yunmu2 : YUNMU) {
						list.add(shengmu1 + yunmu1 + shengmu2 + yunmu2);
					}
				}
			}
		}
		return list;
	}

	public static List<String> genPinyin1() {
		List<String> list = new ArrayList<String>((int)Math.pow(2,11));
		for (String shengmu : SHENGMU) {
			for (String yunmu : YUNMU) {
				list.add(shengmu + yunmu);
			}
		}
		return list;
	}

	public static List<String> genZimu4(String start, String end) {
		if(start==null||start.length()<4){
			return null;
		}
		if(end==null||end.length()<4){
			return null;
		}
		int i1 = start.charAt(0);
		int i2 = start.charAt(1);
		int i3 = start.charAt(2);
		int i4 = start.charAt(3);
		
		List<String> list = new ArrayList<String>((int)Math.pow(2,20));
		for (; i1 <= end.charAt(0); i1++) {
			char c1 = (char) (i1);
			for (; i2 <= end.charAt(1); i2++) {
				char c2 = (char) (i2);
				for (; i3 <= end.charAt(2); i3++) {
					char c3 = (char) (i3);
					for (; i4 <= end.charAt(3); i4++) {
						char c4 = (char) ( i4);
						list.add("" + c1 + c2 + c3 + c4);
					}
					i4='a';
				}
				i3='a';
			}
			i2='a';
		}

		return list;
	}

	public static List<String> genZimu3(String start, String end) {

		List<String> list = new ArrayList<String>((int)Math.pow(2,16));
		if(start==null||start.length()<3){
			return null;
		}
		if(end==null||end.length()<3){
			return null;
		}
		
		int i1 = start.charAt(0);
		int i2 = start.charAt(1);
		int i3 = start.charAt(2);
		for (; i1 <= end.charAt(0); i1++) {
			char c1 = (char) (i1);
			for (; i2 <= end.charAt(1); i2++) {
				char c2 = (char) (i2);
				for (; i3 <= end.charAt(2); i3++) {
					char c3 = (char) (i3);
						list.add("" + c1 + c2 + c3 );
				}
				i3='a';
			}
			i2='a';
		}

		return list;
	}

	public static List<String> genShuzi3() {
		List<String> list = new ArrayList<String>((int)Math.pow(2,11));

		for (int ii = 0; ii < 10; ii++) {
			for (int jj = 0; jj < 10; jj++) {
				for (int kk = 0; kk < 10; kk++) {
					list.add("" + ii + jj + kk);
				}
			}
		}
		return list;
	}

	public static List<String> genShuzi5() {

		List<String> list = new ArrayList<String>((int)Math.pow(2,15));
		for (int ii = 0; ii < 10; ii++) {
			for (int jj = 0; jj < 10; jj++) {
				for (int kk = 0; kk < 10; kk++) {
					for (int mm = 0; mm < 10; mm++) {
						for (int nn = 0; nn < 10; nn++) {
							list.add("" + ii + jj + kk + mm + nn);

						}
					}

				}
			}
		}
		return list;
	}

	public static List<String> genShuzi4() {

		List<String> list = new ArrayList<String>();
		for (int ii = 0; ii < 10; ii++) {
			for (int jj = 0; jj < 10; jj++) {
				for (int kk = 0; kk < 10; kk++) {
					for (int mm = 0; mm < 10; mm++) {
						list.add("" + ii + jj + kk + mm);
					}

				}
			}
		}
		return list;
	}

}
